package mapper;

//操作数据库的Mapper接口

import org.apache.ibatis.annotations.*;
import pojo.Brand;

import java.util.List;

public interface BrandMapper {
    //查询所有品牌
    @ResultMap("brandResultMap")
    @Select("select * from t_brand")
    List<Brand> selectAll();

    //单个查询
    @ResultMap("brandResultMap")
    @Select("select * from t_brand where id = #{id}")
    Brand selectById(int id);

    //插入一个品牌
    @Insert("insert into t_brand   values(null,#{brandName},#{companyName},#{ordered},#{description},#{status})")
    void add(Brand brand);

    //修改一个品牌
    @Update("update t_brand set brand_name=#{brandName}," +
            "company_name=#{companyName},ordered=#{ordered}," +
            "description=#{description},status=#{status} where id=#{id}")
    void update(Brand brand);

    //根据id删除品牌
    @Delete("delete from t_brand where id=#{id}")
    void deleteById(int id);
}